//mempool.cpp
#include "mempool.h"

MemPool::MemPool()
{
	Construct();
}
MemPool::~MemPool()
{
	Destruct();
}

int MemPool::Construct()
{
	m_pcData=NULL;
	m_iPoolSize=0;
	return 0;
}

int MemPool::Destruct()
{
	DELETE_ARY_AND_NULL(m_pcData);
	return 0;
}

int MemPool::Init(IN int iPoolSize)
{
	int iRet=-1,i;
	int iResult,iTemp;

	if(m_pcData) SET_RET_AND_GOTO_EXIT(COMMON_ERR_INITED);
	if(iPoolSize<=0) SET_RET_AND_GOTO_EXIT(COMMON_ERR_INVALIDARGS);

	m_pcData=new char[iPoolSize];
	m_iPoolSize=iPoolSize;

	iRet=0;
_Exit:
	return iRet;
}

int MemPool::Swap(MemPool &objTarget)
{
	int iRet=-1,i;
	int iResult,iTemp;
	char *pcTemp;

	pcTemp=m_pcData;
	iTemp=m_iPoolSize;
	m_pcData=objTarget.m_pcData;
	m_iPoolSize=objTarget.m_iPoolSize;
	objTarget.m_pcData=pcTemp;
	objTarget.m_iPoolSize=iTemp;

	iRet=0;
_Exit:
	return iRet;
}
